﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TamTreSoSinh.DBContext;

namespace TamTreSoSinh.UC
{
    public partial class CustomerPart : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadData();
        }

        private void LoadData()
        {
            DBTamTreEntities dbContext = new DBTamTreEntities();
            List<Customer> listCustomer = dbContext.Customers.OrderBy(obj => obj.Priority).ToList();

            rptCustomer.DataSource = listCustomer;
            rptCustomer.DataBind();
        }

        protected void rptCustomer_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Customer customer = (Customer)e.Item.DataItem;
            
            Image img = (Image)e.Item.FindControl("imgCustomer");
            img.ImageUrl = customer.ImagePath;

            Literal ltr = (Literal)e.Item.FindControl("ltrCustomer");
            ltr.Text = customer.CustomerContent;
        }
    }
}